import request from "@/utils/request";
import {
  ArticleVo,
  ArticleMdFrom,
  ArticleQuery,
  RandomImgFrom,
} from "@/api/article/type";

const api = "/article";

// 查询文章列表数据
export function getArticlePageApi(data: ArticleQuery): PageResult<ArticleVo> {
  return request({
    url: `${api}/page`,
    method: "get",
    params: data,
  });
}

/** 保存或者更新 */
export function saveOrUpdateArticleApi(data: any): Result<number> {
  return request({
    url: `${api}/saveOrUpdate`,
    method: "post",
    data: data,
  });
}

/** 编辑 */
export function editVoByIdApi(id: any): Result<ArticleMdFrom> {
  return request({
    url: `${api}/editVo/${id}`,
    method: "get",
  });
}

export function randomImgApi(data: RandomImgFrom): Result<string> {
  return request({
    url: `${api}/randomImg`,
    method: "post",
    data: data,
  });
}

export function pushApi(data: ArticleMdFrom): Result<void> {
  return request({
    url: `${api}/push`,
    method: "post",
    data: data,
  });
}
